<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page session="true" %>
<%@ page import="javax.portlet.*" %>
<%@page import ="rai.dto.*" %>
<%@page import = "java.util.*" %>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<portlet:defineObjects/>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Personal Information Tracking System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript" src='<%=request.getContextPath() +"/js/calendarDateInput.js"%>'></script> 
<script type="text/javascript">
    function getForm(namespace, name) {
        return document.forms[namespace + name];
    }
    function back_to_emp_info_form_1(namespace, name) {
        var frm = getForm(namespace, name);
        frm.txtAction.value = "back_to_empInfo_form_1";
        frm.submit();
        }
    function back_to_emp_info_form_2(namespace, name) {
        var frm = getForm(namespace, name);
        frm.txtAction.value = "back_to_empInfo_form_2";
        frm.submit();
        }
    function back_to_login(namespace, name) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = "back_to_login_form";
		frm.submit();
	}
	function update_emp_info(namespace,name){
		var frm = getForm(namespace, name);
		frm.txtAction.value = "update_emp_info";
		frm.submit();
		}
</script>
<link href="style/style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<% String CurrentID =(String)session.getAttribute("PassingEmpID"); 
	String name,birthday,address,phone,email;
	if(CurrentID!=null && !CurrentID.equals("") ){
		   name=(String) session.getAttribute("PassingEmpName");
		   birthday=(String) session.getAttribute("PassingEmpBirthday");
		   address=(String) session.getAttribute("PassingEmpAddress");
		   phone=(String) session.getAttribute("PassingEmpPhone");
		   email=(String) session.getAttribute("PassingEmpEmail");
	}
	else{
		   name=(String) session.getAttribute("editEmpName");
		   birthday=(String) session.getAttribute("editBirthday");
		   address=(String) session.getAttribute("editAddress");
		   phone=(String) session.getAttribute("editPhone");
		   email=(String) session.getAttribute("editEmail");
	} %>
<body>
<form name="<portlet:namespace/>editInfoForm" action="<portlet:actionURL/>" method="POST">
	<input type="hidden" name="txtAction" />
<table align="center">
	<tr class="title">
			<td>		
					<h1><font color="blue">Personal information tracking system </font></h1>
					<p>Exploit the value of data</p>
					<hr />
			</td>
	</tr>
	<tr>
		<td colspan="2" align="left"> Welcome, <font color="orange"/><b>[${sessionScope.role}]${sessionScope.name}</b></font>
		| <a href="#" >Home</a>
		| <a href="#" onclick="back_to_login('<portlet:namespace/>','editInfoForm')">Logout</a>
	   </td>
	</tr>
	<tr>				
		<td>
			<table border="1" width="522" align="center" cellpadding="2" cellspacing="2">
				<tr>
					<td colspan="2"><h2 class="title" align="center"><font color="orange">Edit Personal Information</font></h2></td>
				</tr>
				<tr>
					<td width="25%">Name</td>
				  <td width="75%"><input name="txtEmpName" type="text" size="40"  value='<%=name%>'/></td>
				</tr>
				<tr>
				<td>Birthday</td>
					<td> 
					<%String path= request.getContextPath(); %>
					<script>DateInput('txtBirthday',true,'DD/MM/YYYY','<%=path%>','<%=birthday%>');</script></td> 
				</tr>
				<tr>
					<td>Address</td>
					<td><input name="txtAddress" type="text" size="40" value='<%=address%>' /></td>
				</tr>
				<tr>
					<td>Email</td>
					<td><input name="txtEmail" type="text" size="40" value='<%=email%>' /></td>
				</tr>
				<tr>
					<td>Phone</td>
					<td><input name="txtPhone" type="text" size="40"  value='<%=phone%>' /></td>
				</tr>
				<tr>
				 <td><input name="" type="button" value="Update" onclick="update_emp_info('<portlet:namespace/>','editInfoForm')"/>
				     <input name="" type="button" value="Cancel" <%if(CurrentID!=null && !CurrentID.equals("")){%> onclick="back_to_emp_info_form_2('<portlet:namespace/>','editInfoForm')"
				     														<%}else{%> onclick="back_to_emp_info_form_1('<portlet:namespace/>','editInfoForm')"<%} %>/>  	
				 </td>
				 <td width='75%'><font color='red'><b>${sessionScope.errorMess}</b></font>
				 	 <font color='blue'><b>${sessionScope.succMess}</b></font>
				 </td>
				</tr>
			</table>
		</td>
	</tr>
	
	<tr>
		<td>
			<p>Version 1.1</p>
			<div style="clear: both;">&nbsp;</div>
		</td>
	</tr>
</table>
</form>
</body>
